package com.winshare.saleAssistant.domain.dto.req;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.NotNull;
import java.util.List;

@ApiModel
@Data
public class fileQueryDTO {

    @Length(min = 0, max = 100, message = "标题长度需要在1-100个字之间")
    @ApiModelProperty(value = "标题")
    private String fileTitle;

    @Range(min = 0, max = 2, message = "状态：0-禁用,1-启用,3-全部")
    @ApiModelProperty(value = "状态：0-禁用,1-启用")
    private Integer status;

    @NotNull(message = "每页数量不能为空")
    @Range(min = 1)
    @ApiModelProperty(value = "每页数量，建议10-20")
    private Integer pageSize;

    @NotNull(message = "第几页 字段为能为空")
    @Range(min = 1)
    @ApiModelProperty(value = "第几页，从1开始")
    private Integer pageIndex;

    @JsonIgnore
    @ApiModelProperty(hidden = true)
    public Integer getOffsetIndex() {
        return pageSize * (pageIndex < 1 ? 0 : pageIndex - 1);
    }

    public fileQueryDTO() {
    }
}
